package com.four.basicinfo.controller;

import com.four.basicinfo.code.ResponseData;
import com.four.basicinfo.dao.AbroadDao;
import com.four.basicinfo.dao.DocumentDao;
import com.four.basicinfo.entity.Abroad;
import com.four.basicinfo.entity.Document;
import com.four.basicinfo.service.AbroadService;
import com.four.basicinfo.service.DocumentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/abroad")
@CrossOrigin
public class AbroadController extends BaseController{
    @Autowired
    AbroadDao abroadDao;
    @Autowired
    AbroadService abroadService;
    /**
     * 获取基本信息详细信息
     */
    @GetMapping("/selectById")
    public Abroad getInfo(Long id)
    {
        Abroad abroad=abroadService.selectAbroadById(id);
        return abroad;
    }
    /**
     * 查询本人的出国列表
     */
    @GetMapping("/listBynum")
    public List<Abroad> list(Integer number){
        List<Abroad> list = abroadDao.selectByNum(number);
        return list;
    }
    //修改
    @PutMapping("/update")
    public ResponseData<Boolean> update(Abroad abroad){
        Boolean b = abroadService.updateAbroad( abroad )>0;
        return returnBoolean( b );
    }

    //新增
    @PostMapping("/insert")
    public ResponseData<Boolean> insert(Abroad abroad){
        Boolean b = abroadService.insertAbroad( abroad )>0;
        return returnBoolean( b );
    }
    //删除
    @DeleteMapping("/delete")
    public ResponseData<Boolean> delete(Long id){
        Boolean b=abroadService.deleteAbroadById(id)>0;
        return returnBoolean( b );
    }
}
